package com.sdreport.cityReport.javaBeans;

import com.sdreport.cityReport.utils.JDBC;
import java.util.ArrayList;
import java.sql.SQLException;

public class SelectAllGroups extends JDBC {
    private String cityId="";
    private ArrayList groupNames = new ArrayList();
    private ArrayList groupIds = new ArrayList();

    public SelectAllGroups() {

    }
public void setCityId(String cityid){
    this.cityId=cityid;
    this.selectTable();
}
    public ArrayList getGroupNames() {
        return groupNames;
    }

    public ArrayList getGroupIds() {
        return groupIds;
    }

    private void selectTable() {
        this.getConn(this.cityId);
        this.createStatement();
        this.executeQuery("select * from dim_report_groups where city_id="+this.cityId+" order by group_id");
        try {
            while (this.rs.next()) {
                groupIds.add(this.rs.getString("group_id"));
                groupNames.add(this.rs.getString("group_name"));
            }
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        } finally {
            this.close();
        }
    }

   /* public static void main(String[] args) {
         SelectAllGroups selectallgroups = new SelectAllGroups();
         System.out.println(selectallgroups.getGroupIds());
          System.out.println(selectallgroups.getGroupNames());
     } */
}
